package com.guigu.www.erp.dehao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.www.erp.common.pojo.MProcedureModuling;
import com.guigu.www.erp.common.pojo.MProceduring;
import com.guigu.www.erp.dehao.dao.MProcedureModulingMapper;
import com.guigu.www.erp.dehao.dao.MProceduringMapper;
import com.guigu.www.erp.common.pojo.MManufacture;
import com.guigu.www.erp.common.pojo.PageVo;
import com.guigu.www.erp.dehao.dao.MManufactureMapper;
import com.guigu.www.erp.dehao.service.DHMProceduringService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class DHMProceduringServiceImpl implements DHMProceduringService {

    @Autowired
    private MManufactureMapper mManufactureMapper;

    @Autowired
    private MProceduringMapper mProceduringMapper;

    @Autowired
    private MProcedureModulingMapper mProcedureModulingMapper;

    @Override
    public PageVo<MManufacture> queryManufactureProcedureTag01(Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<MManufacture> mManufactures = mManufactureMapper.queryManufactureProcedureTag01();
        PageInfo<MManufacture> info = new PageInfo<>(mManufactures);
        return new PageVo<>(info.getTotal(),info.getList());
    }

    @Override
    public Integer queryByCheckTag01() {
        return mManufactureMapper.queryByCheckTag01();
    }

    @Override
    public void insertSelectMProceduring(MProceduring mProceduring) {
        mProceduringMapper.insertSelective(mProceduring);
    }

    @Override
    public void insertSelectModuling(MProcedureModuling mProcedureModuling) {
        mProcedureModulingMapper.insertSelective(mProcedureModuling);
    }

    @Override
    public PageVo<MManufacture> queryManufactureProcedureTag1(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<MManufacture> mManufactures = mManufactureMapper.queryManufactureProcedureTag1();
        PageInfo<MManufacture> info = new PageInfo<>(mManufactures);
        return new PageVo<>(info.getTotal(),info.getList());
    }

    @Override
    public Integer queryByCheckTag1AndProcedure1() {
        return mManufactureMapper.queryByCheckTag1AndProcedure1();
    }

    @Override
    public void upMProceduringByParentIdAndProId(MProceduring mProceduring) {
        mProceduringMapper.upMProceduringByParentIdAndProId(mProceduring);
    }

    @Override
    public MProceduring queryByParentIdProceduring(Integer parentId, String procedureId) {
        return mProceduringMapper.queryByParentIdProceduring(parentId, procedureId);
    }

    @Override
    public PageVo<MManufacture> findAllMManufactureByCheckTag1(Integer pageNum, Integer pageSize,String manufactureId) {
        PageHelper.startPage(pageNum,pageSize);
        List<MManufacture> allMManufactureByCheckTag1 = mManufactureMapper.findAllMManufactureByCheckTag1("%"+manufactureId+"%");
        PageInfo<MManufacture> info = new PageInfo<>(allMManufactureByCheckTag1);
        return new PageVo<>(info.getTotal(),info.getList());
    }

    @Override
    public Integer queryManufactureCountBy12() {
        return mManufactureMapper.queryManufactureCountBy12();
    }


}
